package com.example.wangzh.developkit.control;

import android.view.Gravity;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;

import com.example.wangzh.developkit.R;
import com.example.wangzh.developkit.base.BaseActivity;

import butterknife.BindView;

/**
 * Created by wangzh on 2017/10/19.
 */

public class AmountSelectorActivity extends BaseActivity {
    @BindView(R.id.lnl_parent)
    LinearLayout lnl_parent;
    @BindView(R.id.btn_show_pop)
    Button btn;
    LockGoodsPopupManager lockGoodsPopupManager;
    @Override
    protected int getLayout() {
        return R.layout.activity_amount_selector;
    }

    @Override
    protected void initView() {
        initLockGoodsPop();
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                lockGoodsPopupManager.showAtLocation(lnl_parent, Gravity.BOTTOM, 0, 0);
            }
        });
    }

    private void initLockGoodsPop() {
        lockGoodsPopupManager = new LockGoodsPopupManager(this);
        lockGoodsPopupManager.setStockAmount(100);
        lockGoodsPopupManager.setPrice(10);
        lockGoodsPopupManager.setMaxMesh(500);
        lockGoodsPopupManager.setMinMesh(100);
        lockGoodsPopupManager.setNeedMesh(true);
        lockGoodsPopupManager.setOnGoodsLockedListener(new LockGoodsPopupManager.OnGoodsLockedListener( ) {
            @Override
            public void onGoodsLocked(double amount) {
                Toast.makeText(AmountSelectorActivity.this, "确认锁货", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
